from enum import Enum, unique
# from random import random
import random

allStudentObject  = []
class Person:
    def __init__(self, per_id, per_name):
        self.per_id = per_id
        self.name = per_name


class Student(Person):
    allStudent = []

    def __init__(self, stu_id, name, addr, courses=[]):
        super().__init__(stu_id, name)
        self.addr = addr
        self.courses = courses
        allStudentObject.append(self)

    def all_info(self):
        print("学号：%d 姓名：%s 家庭住址：%s 选课：%s" % (self.per_id, self.name, self.addr, self.courses))

    def arrange(self):
        NullList = []
        for x in range(3):
            choice = random.randint(0, 5)
            while AiClass(choice).name in NullList:
                choice = random.randint(0, 5)
            NullList.append(AiClass(choice).name)
        # self.courses = NullList
        Student.allStudent.append([self.name, self.per_id, self.addr, self.courses])
# [['lgr',1,'taiyuan',['AI',]],[],[],....]

    @staticmethod
    def all_detail_info():
        for i in range(len(Student.allStudent)):
            print('学生姓名：%s  学号：%d   院校：%s\n'
                  '所选课程：%s  \n'
                  '任课老师电话：%s' % (Student.allStudent[i][0], Student.allStudent[i][1], Student.allStudent[i][2],
                                 Student.allStudent[i][3], Course.getPhoneByCourse(Student.allStudent[i][3])))
            print()

class Teacher(Person):
    allTeacher = []

    def __init__(self, teach_id, name, phone):
        super().__init__(teach_id, name)
        self.phone = phone
        Teacher.allTeacher.append([self.name, self.per_id, self.phone])
        # print(Teacher.allTeacher)


class Course():
    allCourse = []

    def __init__(self, cour_id, cour_name, cour_teacher, cour_students=[]):
        self.cour_id = cour_id
        self.cour_name = cour_name
        self.cour_teacher = cour_teacher
        self.cour_students = cour_students
        Course.allCourse.append([self.cour_id, self.cour_name, self.cour_teacher])

    @classmethod
    def getPhoneByCourse(cls, courseName):
        phoneList = []
        # print(courseName)
        for n in range(len(courseName)):
            for i in range(len(Course.allCourse)):
                # print(courseName[n])
                # print(Teacher.allTeacher[i][0])
                if courseName[n] == Course.allCourse[i][1]:
                    phoneList.append(Course.allCourse[i][2])
        return phoneList


@unique
class AiTeacher(Enum):
    李国瑞 = 0
    单振峰 = 1
    高瑞 = 2
    屈智霖 = 3
    张越 = 4
    王培云 = 5


@unique
class AiClass(Enum):
    MachineLearning = 0
    DepthLearning = 1
    Python = 2
    Math = 3
    probability_Theory = 4
    linear_Algebra = 5


if __name__ == '__main__':
    all_student_name = ['李国瑞', '单振峰', '高瑞', '屈智霖', '张越', '王培云', '包乐尔夫', '陈丹', '耿文俊',
                        '李梦佳', '屈润利', '田翊扬', '王佳龙', '王仲媛', '张银晗', '胡康成', '林子祺', '范益佳', '叶萌'
        , '冀港', '王士博', '张瑞宏', '韦双迎', '张维加', '张一乐', '原傲', '张玉洁', '刘珊池', '王洋', '薛晓飞']
    phone = 19903439208
    # 创建老师
    for i in range(len(AiTeacher)):
        new_teacher = Teacher(AiTeacher(i).value, AiTeacher(i).name, phone + i)
    print(Teacher.allTeacher)
    # 绑定老师与课程
    for i in range(len(AiClass)):
        new_class = Course(AiClass(i).value, AiClass(i).name, Teacher.allTeacher[i])
    # 创建30名学生
    for i in list(range(30)):
        # print(i,all_student_name[i])
        new_student = Student(i, all_student_name[i], "太原理工大学")
        new_student.arrange()
    new_student.all_detail_info()

    s1 = Student(1,'kk','s',[])